From 0adb31cfd2217bdea4fb172a71eda86e47a8f61f Mon Sep 17 00:00:00 2001 From: robertl Date: Tue, 19 Aug 2008 19:29:16 +0000 Subject: [PATCH] Misc const tweaks. --- bcr.c | 12 ++++++------ defs.h | 24 ++++++++++++------------ garmin_tables.c | 10 +++++----- garmin_tables.h | 4 ++-- gcdb.c | 2 +- geoniche.c | 2 +- igo8.c | 6 ++---- mtk_logger.c | 2 +- osm.c | 2 +- palmdoc.c | 2 +- raymarine.c | 6 +++--- unicsv.c | 4 ++-- util.c | 11 ++++++----- xmldoc/chapters/use.xml | 37 +++++++++++++++++++++++++++++++------ 14 files changed, 74 insertions(+), 50 deletions(-) diff --git a/bcr.c b/bcr.c index fd78de045..690aed3ee 100644 --- a/bcr.c +++ b/bcr.c @@ -77,9 +77,9 @@ arglist_t bcr_args[] = { }; typedef struct { - char *bcr_name; - char *mps_name; - char *symbol_DE; + const char *bcr_name; + const char *mps_name; + const char *symbol_DE; int warned; } bcr_icon_mapping_t; @@ -145,10 +145,10 @@ bcr_handle_icon_str(const char *str, waypoint *wpt) } } -static char * +static const char * get_bcr_icon_from_icon_descr(const char *icon_descr) { - char *result = BCR_DEF_ICON; + const char *result = BCR_DEF_ICON; if (icon_descr) { bcr_icon_mapping_t *m; @@ -378,7 +378,7 @@ bcr_route_header(const route_head *route) i = 0; QUEUE_FOR_EACH(&route->waypoint_list, elem, tmp) { - char *icon; + const char *icon; waypoint *wpt = (waypoint *) elem; i++; diff --git a/defs.h b/defs.h index d96dfda3d..2b5528d0c 100644 --- a/defs.h +++ b/defs.h @@ -656,14 +656,14 @@ void vmem_realloc(vmem_t*, size_t); #define ARG_TERMINATOR {0, 0, 0, 0, 0, ARG_NOMINMAX} typedef struct arglist { - char *argstring; + const char *argstring; char **argval; - char *helpstring; - char *defaultvalue; - gbuint32 argtype; - char *minvalue; /* minimum value for numeric options */ - char *maxvalue; /* maximum value for numeric options */ - char *argvalptr; /* !!! internal helper. Not used in definitions !!! */ + const char *helpstring; + const char *defaultvalue; + const gbuint32 argtype; + const char *minvalue; /* minimum value for numeric options */ + const char *maxvalue; /* maximum value for numeric options */ + const char *argvalptr; /* !!! internal helper. Not used in definitions !!! */ } arglist_t; typedef enum { @@ -717,7 +717,7 @@ typedef struct ff_vecs { ff_write write; ff_exit exit; arglist_t *args; - char *encode; + const char *encode; int fixed_encode; position_ops_t position_ops; const char *name; /* dyn. initialized by find_vec */ @@ -832,7 +832,7 @@ char * strip_html(const utf_string*); char * strip_nastyhtml(const char * in); char * convert_human_date_format(const char *human_datef); /* "MM,YYYY,DD" -> "%m,%Y,%d" */ char * convert_human_time_format(const char *human_timef); /* "HH+mm+ss" -> "%H+%M+%S" */ -char * pretty_deg_format(double lat, double lon, char fmt, char *sep, int html); /* decimal -> dd.dddd or dd mm.mmm or dd mm ss */ +char * pretty_deg_format(double lat, double lon, char fmt, const char *sep, int html); /* decimal -> dd.dddd or dd mm.mmm or dd mm ss */ char * get_filename(const char *fname); /* extract the filename portion */ @@ -855,9 +855,9 @@ char * get_filename(const char *fname); /* extract the filename portion */ /* this lives in gpx.c */ time_t xml_parse_time( const char *cdatastr, int * microsecs ); -xml_tag *xml_findfirst( xml_tag *root, char *tagname ); -xml_tag *xml_findnext( xml_tag *root, xml_tag *cur, char *tagname ); -char *xml_attribute( xml_tag *tag, char *attrname ); +xml_tag *xml_findfirst( xml_tag *root, const char *tagname ); +xml_tag *xml_findnext( xml_tag *root, xml_tag *cur, const char *tagname ); +char *xml_attribute( xml_tag *tag, const char *attrname ); char * rot13( const char *str ); diff --git a/garmin_tables.c b/garmin_tables.c index 7524bb97c..956612b78 100644 --- a/garmin_tables.c +++ b/garmin_tables.c @@ -603,8 +603,8 @@ char *gt_display_mode_names[] = { }; typedef struct { - char *shortname; - char *longname; + const char *shortname; + const char *longname; grid_type grid; } grid_mapping_t; @@ -624,8 +624,8 @@ grid_mapping_t gt_mps_grid_names[] = /* gt_mps_datum_names: */ typedef struct { - char *jeeps_name; - char *mps_name; + const char *jeeps_name; + const char *mps_name; } datum_mapping_t; /* will be continued (when requested) */ @@ -647,7 +647,7 @@ static datum_mapping_t gt_mps_datum_names[] = }; typedef struct garmin_color_s { - char *name; + const char *name; gbint32 rgb; } garmin_color_t; diff --git a/garmin_tables.h b/garmin_tables.h index d23ede9cc..c1a23b5e6 100644 --- a/garmin_tables.h +++ b/garmin_tables.h @@ -61,8 +61,8 @@ extern char *gt_waypt_class_names[]; typedef struct gt_country_code_s { - char *cc; - char *country; + const char *cc; + const char *country; } gt_country_code_t; extern gt_country_code_t gt_country_codes[]; diff --git a/gcdb.c b/gcdb.c index 0509e6546..585f7c34b 100644 --- a/gcdb.c +++ b/gcdb.c @@ -179,7 +179,7 @@ data_read(void) static int -gcdb_add_to_rec(struct dbrec *rec, char *fldname, gcdb_rectype rectype, void *data) +gcdb_add_to_rec(struct dbrec *rec, const char *fldname, gcdb_rectype rectype, void *data) { int length; static int rec_cnt; diff --git a/geoniche.c b/geoniche.c index d9a6c0f53..205d5847d 100644 --- a/geoniche.c +++ b/geoniche.c @@ -359,7 +359,7 @@ geoniche_read_asc(void) } } -static char *geoniche_icon_map[] = /* MPS */ +static const char *geoniche_icon_map[] = /* MPS */ { /* 21 */ "Cross", /* 22 */ "Cross (light)", diff --git a/igo8.c b/igo8.c index cb9576f65..3f8f72b4b 100644 --- a/igo8.c +++ b/igo8.c @@ -309,8 +309,8 @@ void write_header() igo8_id_block tmp_id_block; p_igo8_id_block id_block = (p_igo8_id_block)header; gbuint32 current_position = 0; - char* title = "Title"; - char* description = "Description"; + const char* title = "Title"; + const char* description = "Description"; // These values seem to be constant for me, but I have no idea what they are. tmp_id_block.unknown_1 = 0x0000029B; @@ -384,5 +384,3 @@ ff_vecs_t igo8_vecs = { CET_CHARSET_UTF8, 1 }; - - diff --git a/mtk_logger.c b/mtk_logger.c index 12273658e..e056d6477 100644 --- a/mtk_logger.c +++ b/mtk_logger.c @@ -754,7 +754,7 @@ static void mtk_csv_deinit(void){ static int csv_line(gbfile *csvFile, int idx, unsigned long bmask, struct data_item *itm){ struct tm *ts_tm; char ts_str[30]; - char *fix_str = ""; + const char *fix_str = ""; ts_tm = gmtime(&(itm->timestamp)); strftime(ts_str, sizeof(ts_str)-1, "%Y/%m/%d,%H:%M:%S", ts_tm); diff --git a/osm.c b/osm.c index 0835d3bd4..54c3aae33 100644 --- a/osm.c +++ b/osm.c @@ -65,7 +65,7 @@ xg_tag_mapping osm_map[] = { { NULL, 0, NULL } }; -static char *osm_features[] = { +static const char *osm_features[] = { "- dummy -", /* 0 */ "aeroway", /* 1 */ "amenity", /* 2 */ diff --git a/palmdoc.c b/palmdoc.c index 004e534e7..d6f0b55e6 100644 --- a/palmdoc.c +++ b/palmdoc.c @@ -309,7 +309,7 @@ static void create_bookmark( char *bmtext ) { bookmark_tail = newmark; } -static void docprintf( int maxlen, char *format, ... ) { +static void docprintf( int maxlen, const char *format, ... ) { char *txt = NULL; char *txt2 = NULL; diff --git a/raymarine.c b/raymarine.c index adc4e38d4..b7c9f0c33 100644 --- a/raymarine.c +++ b/raymarine.c @@ -80,8 +80,8 @@ arglist_t raymarine_args[] = /* Bitmaps */ typedef struct { - char *name; - char *mps_name; + const char *name; + const char *mps_name; } raymarine_symbol_mapping_t; static raymarine_symbol_mapping_t raymarine_symbols[] = { @@ -387,7 +387,7 @@ static void write_route_wpt_cb(const waypoint *wpt) { int i; - static char *items[] = { + static const char *items[] = { "Cog", "Eta", "Length", diff --git a/unicsv.c b/unicsv.c index cdbc7d627..1237bd7d8 100644 --- a/unicsv.c +++ b/unicsv.c @@ -109,7 +109,7 @@ typedef enum { #define unicsv_unknown 1e25 typedef struct { - char *name; + const char *name; field_e type; gbuint32 options; } field_t; @@ -215,7 +215,7 @@ static field_e *unicsv_fields_tab; static int unicsv_fields_tab_ct; static double unicsv_altscale, unicsv_depthscale, unicsv_proximityscale ; -static char *unicsv_fieldsep; +static const char *unicsv_fieldsep; static gbfile *fin, *fout; static gpsdata_type unicsv_data_type; static route_head *unicsv_track, *unicsv_route; diff --git a/util.c b/util.c index 07bd7355e..175f42750 100644 --- a/util.c +++ b/util.c @@ -621,7 +621,8 @@ char * strenquote(const char *str, const char quot_char) { int len; - char *cin, *cout; + const char *cin; + char *cout; char *tmp; if (str == NULL) cin = ""; @@ -1371,7 +1372,7 @@ convert_human_time_format(const char *human_timef) * html = 1 for html output otherwise text */ char * -pretty_deg_format(double lat, double lon, char fmt, char *sep, int html) +pretty_deg_format(double lat, double lon, char fmt, const char *sep, int html) { double latmin, lonmin, latsec, lonsec; int latint, lonint; @@ -1695,7 +1696,7 @@ xml_tag *xml_next( xml_tag *root, xml_tag *cur ) return cur; } -xml_tag *xml_findnext( xml_tag *root, xml_tag *cur, char *tagname ) +xml_tag *xml_findnext( xml_tag *root, xml_tag *cur, const char *tagname ) { xml_tag *result = cur; do { @@ -1704,12 +1705,12 @@ xml_tag *xml_findnext( xml_tag *root, xml_tag *cur, char *tagname ) return result; } -xml_tag *xml_findfirst( xml_tag *root, char *tagname ) +xml_tag *xml_findfirst( xml_tag *root, const char *tagname ) { return xml_findnext( root, root, tagname ); } -char *xml_attribute( xml_tag *tag, char *attrname ) +char *xml_attribute( xml_tag *tag, const char *attrname ) { char *result = NULL; if ( tag->attributes ) { diff --git a/xmldoc/chapters/use.xml b/xmldoc/chapters/use.xml index 6c5a2970b..68b60d459 100644 --- a/xmldoc/chapters/use.xml +++ b/xmldoc/chapters/use.xml @@ -287,19 +287,44 @@ merged data to multiple destinations. Introduced in GPSBabel 1.3.1, we now have an experimental feature for realtime tracking via the new option. This reads position reports from selected formats and writes an output file when a position report is received. - As of this writing, Garmin's PVT protocol and NMEA are supported + As of this writing, Garmin's PVT + protocol and + NMEA are supported inputs. KML, NMEA, and the variou XCSV formats are supported on output. Additional formats may be added by interested parties later. Read realtime positioning from Garmin USB, write to Keyhole Markup - gpsbabel -T -i garmin -f usb: -o kml -F xxx.kml - - + gpsbabel -T -i garmin -f usb: -o kml -F xxx.kml + Will read the USB-connected Garmin and rewrite 'xxx.kml' atomically, - suitable for a self-refreshing network link in Google Earth. - + suitable for a self-refreshing network link in Google Earth. + + + + + Read realtime positioning from Wintec WBT-201 via Bluetooth on Mac, write to Keyhole Markup + gpsbabel -T -i nmea -f /dev/cu.G-Rays2-SPPslave-1 -o kml -F xxx.kml + + Will read the Wintec WBT-201 via Bluetooth, using the name that + the Mac assigned it, and rewrite 'xxx.kml' atomically, + suitable for a self-refreshing network link in Google Earth. + + + + + + Be sure to substitute an device name appropriate for your device + and OS, such as /dev/cu.usbserial or + /dev/cu.BT-GPS-37A695-BT-GPSCOM-1 + for Mac, COM23: for Windows, or + usb: for + Garmin USB. These names + (except the "usb:" parlance for Garmin USB) are assigned by + your operating system. + + -- 2.30.2